package top.kaoshanji.p2ch10a;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * 代码清单-p2ch10a-313页a：说明构造方法调用顺序的示例
 * author kaoshanji
 * ^_^
 * create time 2025/2/2 17:16
 */
public class NewObject {

    private static final Logger logger = LogManager.getLogger(NewObject.class);

    public static void main(String[] args) {
        logger.info("...代码清单-p2ch10a-313页a：说明构造方法调用顺序的示例...");

        Dog dog = new Dog();
        System.out.println(dog.legs);

    }

}

class Animal {

    int legs = 0;

    public Animal(int legs) {
        System.out.println("Animal constructor");
        this.legs = legs;
    }
}

class Dog extends Animal {
    String name = "<default>";

    public Dog() {
        super(4);
        System.out.println("Dog constructor");
    }
}

